/*
 * @Author: zqx me_zqx@163.com
 * @Date: 2025-08-26 17:40:01
 * @LastEditors: zqx me_zqx@163.com
 * @LastEditTime: 2025-09-09 19:24:48
 * @FilePath: /XMate-h5/src/services/business/index.js
 * @Description: 
 * 
 * Copyright (c) 2025 by ${git_name_email}, All Rights Reserved. 
 */

import { http, fetchPost } from "@/utils/http";
import { v4 as uuidv4 } from "uuid";

// 取得商机沟通记录
export const opportunityVisitRecordAPI = (opportunityId, data) => {
  return http.request({
    url: `/rest/api/opportunity/${opportunityId}/meetings`,
    method: "POST",
    data
  });
};

// 取得商机风险信息
export const getBusinessRiskAPI = opportunityId => {
  return http.request({
    url: `/rest/api/opportunity/${opportunityId}/risks`,
    method: "GET"
  });
};

// 取得商机参会人
export const opportunityAttendeeAPI = (opportunityId, data) => {
  return http.request({
    url: `/rest/api/aichat/opportunity/${opportunityId}/contacts`,
    method: "POST",
    data,
    disableProgress: true
  });
};

// 取得商机待办
export const getOpportunityTodoListAPI = (opportunityId, data) => {
  return http.request({
    url: `/rest/api/opportunity/${opportunityId}/todos`,
    method: "POST",
    data
  });
};

// 更新商机待办
export const updateOpportunityTodoStatusAPI = (confId, todoId, data) => {
  return http.request({
    url: `/rest/api/conference/${confId}/todo/${todoId}`,
    method: "PUT",
    data
  });
};

// 取得商机竞争对手
export const getOpportunityCompetitorsAPI = (opportunityId, data) => {
  return http.request({

    url: `/rest/api/opportunity/${opportunityId}/competitors`,
    method: "POST",
    data
  });
};

// 取得竞争对手详情
export const getOpportunityCompetitorDetailAPI = (opportunityId, competitorId) => {
  return http.request({
    url: `/rest/api/opportunity/${opportunityId}/competitor/${competitorId}/analysis`,
    method: "GET"
  });
};

// 取得竞争对手详情
// export const getCompetitorsDetailAPI = (customerId, competitorId) => {
//   return http.request({
//     url: `/rest/api/aichat/customer/${customerId}/competitor/${competitorId}/analysis`,
//     method: "GET"
//   });
// };

// 取得商机详情
export const getOpportunityDetailAPI = opportunityId => {
  return http.request({
    url: `/rest/api/opportunity/${opportunityId}`,
    method: "POST"
  });
};

// ----------------------  meddic ----------------------
// 后端复用的customer ， 这里用opportunityId即可
// 获取客户MEDDIC
export const getOpportunityMeddicAPI = opportunityId => {
  return http.request({
    url: `/rest/api/meddic/customer/${opportunityId}`,
    method: "GET"
  });
};

// 更新客户MEDDIC
export const updateOpportunityMeddicAPI = data => {
  return http.request({
    url: `/rest/api/meddic/`,
    method: "PUT",
    data,
    disableProgress: true
  });
};

// 重新生成客户MEDDIC
export const remakeOpportunityMeddicAPI = opportunityId => {
  return http.request({
    url: `/rest/api/conference/report/customer/${opportunityId}/meddic`,
    method: "GET",
    timeout: 6000000,
    disableToast: true
  });
};

// ----------------------  end ----------------------